package ua.mykola.backtracking;

public class AllStringCombinations {

	public static void main(String[] args) {
		new AllStringCombinations().combinations("abcd");
	}

	public void combinations(String str) {
		combinations("", str);
	}

	private void combinations(String prefix, String str) {
		System.out.println(prefix);
		for (int i = 0; i < str.length(); i++) {
			combinations(prefix + str.charAt(i), str.substring(i + 1));
		}
	}

}
